package com.tj.bigdata.syncblock.utils;

/**
 * 缓存工具
 */

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class MyCache {
    private static Map<String, Object> cacheMap;

    public static Object getCache(String key, Object defaultValue) {
        Object obj = getCacheMap().get(key);
        return obj == null ? defaultValue : obj;
    }

    public static void putCache(String key, Object value) {
        getCacheMap().put(key, value);
    }

    public static void removeCache(String key) {
        getCacheMap().remove(key);
    }

    public static Map<String, Object> getCacheMap() {
        if (cacheMap == null) {
            cacheMap = new ConcurrentHashMap<String, Object>();
        }
        return cacheMap;
    }
}
